const mongoose = require('./db')

let userSchema = new mongoose.Schema({
    zhanghao: String,
    name: String,
    phone: Number,
    password: String,
    xueli: String,
    minzu: String,
    data: Date,
    img: String,
    roleid: {
        type: mongoose.Types.ObjectId,
        ref: "role"
    },
}, {
    versionKey: false
})


//角色
let roleSchema = new mongoose.Schema({
    name: String,
    menuid: {
        type: [mongoose.Types.ObjectId],
        ref: "menu"
    }
}, {
    versionKey: false
})

//权限
let menuSchema = new mongoose.Schema({
    name: String,
    url: String,
    pid: {
        type: mongoose.Types.ObjectId,
        ref: "menu"
    }
}, {
    versionKey: false
})

//小区
let xiaoquSchema = new mongoose.Schema({
    name: String,
    address: String,
    kfs: String,
    wuye: String,
    time: Date,
}, {
    versionKey: false
})



//人员
let renSchema = new mongoose.Schema({
    name: String,
    sex: String,
    phone: Number,
    time: Date,
    xiaoqu: String,
}, {
    versionKey: false
})



//房屋
let wuziSchema = new mongoose.Schema({
    doorid: String,
    mianji: String,
    huzhu: String,
    xiaoqu: String,
    time: Date,
}, {
    versionKey: false
})

//车库
let carSchema = new mongoose.Schema({
    carid: String,
    color: String,
    ren: String,
    xiaoqu: String,
    time: Date,
}, {
    versionKey: false
})


//任务

let renwuSchema = new mongoose.Schema({
    address: String,
    nandu: String,
    num: Number,
    zhiliang: String,
    jindu: String,
    sta: String,
    fzr: String,

}, {
    versionKey: false
})


let imgsSchema = new mongoose.Schema({
    src: String,
}, {
    versionKey: false
})


let usermodel = mongoose.model('user', userSchema, 'user')
let rolemodel = mongoose.model('role', roleSchema, 'role')
let menumodel = mongoose.model('menu', menuSchema, 'menu')
let xiaoqumodel = mongoose.model('xiaoqu', xiaoquSchema, 'xiaoqu')
let renmodel = mongoose.model('ren', renSchema, 'ren')
let wuzimodel = mongoose.model('wuzi', wuziSchema, 'wuzi')
let carmodel = mongoose.model('car', carSchema, 'car')
let renwumodel = mongoose.model('renwu', renwuSchema, 'renwu')
let imgsmodul = mongoose.model('imgs', imgsSchema, 'imgs')


module.exports = {
    usermodel,
    rolemodel,
    menumodel,
    xiaoqumodel,
    wuzimodel,
    carmodel,
    renmodel,
    renwumodel,
    imgsmodul,
}



